# Maintainer: Natanael Copa <ncopa@alpinelinux.org>
pkgname=samba
pkgver=4.20.5
pkgrel=0
pkgdesc="Tools to access a server's filespace and printers via SMB"
url="https://www.samba.org/"
arch="all"
license="GPL-3.0-or-later AND LGPL-3.0-or-later"
options="!check" # fixme: missing dependencies for '--enable-selftest'
subpackages="
	$pkgname-dev
	$pkgname-doc
	$pkgname-server-openrc
	libwbclient
	$pkgname-util-libs:_util_libs

	$pkgname-common:_common:noarch
	$pkgname-common-tools:_common_tools
	$pkgname-common-server-libs:_common_server_libs
	libsmbclient
	$pkgname-client
	$pkgname-client-libs:_client_libs

	$pkgname-winbind
	$pkgname-winbind-clients:_winbind_clients
	$pkgname-winbind-krb5-locator:_winbind_krb5_locator
	$pkgname-libnss-winbind:_libnss_winbind
	pam-winbind:_pam_winbind

	$pkgname-dc
	$pkgname-dc-libs:_dc_libs

	$pkgname-server
	$pkgname-server-libs:_server_libs
	$pkgname-pidl::noarch
	py3-$pkgname:_py3
	$pkgname-test:_test
	$pkgname-libs-py3:_libs_py3
	libauth-$pkgname:_libauth
	$pkgname-libs
	"

depends="
	$pkgname-server=$pkgver-r$pkgrel
	$pkgname-client=$pkgver-r$pkgrel
	$pkgname-common-tools=$pkgver-r$pkgrel
	"

_dc_deps="py3-dnspython py3-markdown tdb"
# note that heimdal is required (over mit krb5) for AD DC functionality
makedepends="
	acl-dev
	attr-dev
	bind-dev
	bison
	cups-dev
	dbus-dev
	docbook-xsl
	e2fsprogs-dev
	flex
	gnutls-dev
	icu-dev
	iniparser-dev
	jansson-dev
	ldb-dev
	libarchive-dev
	libcap-dev
	libtirpc-dev
	liburing-dev
	linux-pam-dev
	musl-nscd-dev
	ncurses-dev
	openldap-dev
	perl
	perl-parse-yapp
	popt-dev
	py3-ldb
	py3-tdb
	py3-tevent
	python3-dev
	readline-dev
	rpcgen
	subunit-dev
	talloc-dev
	tdb-dev
	tevent-dev
	util-linux-dev
	zlib-dev
	$_dc_deps
	"
#checkdepends="
#	bash
#	py3-asn1
#	py3-cryptography
#	py3-iso8601
#	py3-setproctitle
#	"
source="
	https://download.samba.org/pub/samba/stable/samba-$pkgver.tar.gz
	musl_uintptr.patch
	default-config.patch

	$pkgname.initd
	$pkgname.confd
	$pkgname.logrotate
	"
pkggroups="winbind"

# secfixes:
#   4.18.9-r0:
#     - CVE-2018-14628
#   4.18.8-r0:
#     - CVE-2023-3961
#     - CVE-2023-4091
#     - CVE-2023-4154
#     - CVE-2023-42669
#     - CVE-2023-42670
#   4.18.1-r0:
#     - CVE-2023-0225
#   4.17.0-r0:
#     - CVE-2022-1615
#     - CVE-2022-32743
#   4.16.7-r0:
#     - CVE-2022-42898
#   4.16.6-r0:
#     - CVE-2022-3437
#     - CVE-2022-3592
#   4.15.9-r0:
#     - CVE-2022-2031
#     - CVE-2021-3670
#     - CVE-2022-32744
#     - CVE-2022-32745
#     - CVE-2022-32746
#     - CVE-2022-32742
#   4.15.2-r0:
#     - CVE-2016-2124
#     - CVE-2020-25717
#     - CVE-2020-25718
#     - CVE-2020-25719
#     - CVE-2020-25721
#     - CVE-2020-25722
#     - CVE-2021-23192
#     - CVE-2021-3738
#   4.15.0-r0:
#     - CVE-2021-3671
#   4.14.4-r0:
#     - CVE-2021-20254
#   4.14.2-r0:
#     - CVE-2020-27840
#     - CVE-2021-20277
#   4.12.9-r0:
#     - CVE-2020-14318
#     - CVE-2020-14323
#     - CVE-2020-14383
#   4.12.7-r0:
#     - CVE-2020-1472
#   4.12.5-r0:
#     - CVE-2020-10730
#     - CVE-2020-10745
#     - CVE-2020-10760
#     - CVE-2020-14303
#   4.12.2-r0:
#     - CVE-2020-10700
#     - CVE-2020-10704
#   4.11.5-r0:
#     - CVE-2019-14902
#     - CVE-2019-14907
#     - CVE-2019-19344
#   4.11.3-r0:
#     - CVE-2019-14861
#     - CVE-2019-14870
#   4.11.2-r0:
#     - CVE-2019-10218
#     - CVE-2019-14833
#   4.10.8-r0:
#     - CVE-2019-10197
#   4.10.5-r0:
#     - CVE-2019-12435
#     - CVE-2019-12436
#   4.10.3-r0:
#     - CVE-2018-16860
#   4.8.11-r0:
#     - CVE-2018-14629
#     - CVE-2019-3880
#   4.8.7-r0:
#     - CVE-2018-16841
#     - CVE-2018-16851
#     - CVE-2018-16853
#   4.8.4-r0:
#     - CVE-2018-1139
#     - CVE-2018-1140
#     - CVE-2018-10858
#     - CVE-2018-10918
#     - CVE-2018-10919
#   4.7.6-r0:
#     - CVE-2018-1050
#     - CVE-2018-1057
#   4.7.3-r0:
#     - CVE-2017-14746
#     - CVE-2017-15275
#   4.7.0-r0:
#     - CVE-2017-12150
#     - CVE-2017-12151
#     - CVE-2017-12163
#   4.6.1-r0:
#     - CVE-2017-2619

build() {
	local _idmap_modules=idmap_ad,idmap_rid,idmap_ldap,idmap_hash,idmap_tdb2
	local _pdb_modules=pdb_tdbsam,pdb_ldapsam,pdb_smbpasswd,pdb_wbc_sam,pdb_samba4
	local _auth_modules=auth_unix,auth_wbc,auth_server,auth_script,auth_samba4
	local _vfs_modules=vfs_dfs_samba4

	# pclose, ..
	export CFLAGS="$CFLAGS -O2 -D_BSD_SOURCE -flto=auto"
	./configure \
		--prefix=/usr \
		--sysconfdir=/etc/$pkgname \
		--with-configdir=/etc/$pkgname \
		--localstatedir=/var \
		--libexecdir=/usr/lib \
		--enable-fhs \
		--with-lockdir=/var/cache/$pkgname \
		--with-piddir=/run/$pkgname \
		--with-logfilebase=/var/log/$pkgname \
		--with-pam \
		--without-systemd \
		--with-ads \
		--with-shared-modules=$_idmap_modules,$_pdb_modules,$_auth_modules,$_vfs_modules \
		--enable-cups \
		--without-gettext \
		--bundled-libraries=!talloc,!pytalloc,!pytalloc-util,!tdb,!pytdb,!ldb,!pyldb,!pyldb-util,!tevent,!pytevent,!popt \
		--disable-rpath-install \
		--without-gpgme \
		--disable-fault-handling
	make

	# Build pidl
	cd "$builddir"/pidl
	perl Makefile.PL PREFIX=/usr
}

check() {
	make check
}

package() {
	make DESTDIR="$pkgdir" install

	install -d "$pkgdir"/var/log/$pkgname \
		"$pkgdir"/usr/share/doc/$pkgname
	install -dm755 "$pkgdir"/var/lib/$pkgname/sysvol
	install -Dm644 examples/smb.conf.default \
		"$pkgdir"/etc/$pkgname/smb.conf
	install -m744 packaging/printing/smbprint \
		"$pkgdir"/usr/bin/smbprint
	install -Dm644 "$srcdir"/$pkgname.logrotate \
		"$pkgdir"/etc/logrotate.d/$pkgname

	install -Dm755 "$srcdir/$pkgname.initd" "$pkgdir/etc/init.d/$pkgname"
	install -Dm644 "$srcdir/$pkgname.confd" "$pkgdir/etc/conf.d/$pkgname"

	rm -r "$pkgdir"/run

	# Install pidl
	cd "$builddir"/pidl
	make DESTDIR="$pkgdir" install_vendor
}

_common() {
	pkgdesc="Samba common files for both client an servers"
	depends=
	amove etc var
	install -d -m700 "$subpkgdir"/var/lib/$pkgname/private
}

# samba-libs-py3 is an attempt to avoid libpython dependency for libsmbclient
_libs_py3() {
	pkgdesc="Libraries that require libpython"
	depends="$pkgname-libs=$pkgver-r$pkgrel"
	amove \
		usr/lib/$pkgname/libsamba-net*private-samba.so \
		usr/lib/$pkgname/libsamba-python*private-samba.so
}

# may depend on samba-common-server-libs but not samba-server-libs
_common_tools() {
	pkgdesc="Tools for Samba servers and clients"
	depends="$pkgname-libs=$pkgver-r$pkgrel"
	amove \
		usr/bin/net \
		usr/bin/pdbedit \
		usr/bin/profiles \
		usr/bin/samba-log-parser \
		usr/bin/smbcontrol \
		usr/bin/smbpasswd \
		usr/bin/testparm \
		usr/lib/$pkgname/libgpext-private-samba.so \
		usr/lib/$pkgname/libnet-keytab-private-samba.so
}

# should not depend on client libs
_common_server_libs() {
	pkgdesc="Samba libraries shared by common-tools and servers" # not shared with clients
	depends="$pkgname-libs=$pkgver-r$pkgrel"
	amove \
		usr/lib/libdcerpc-server-core.so.* \
		usr/lib/libnetapi.so.* \
		usr/lib/$pkgname/libRPC-SERVER-LOOP-private-samba.so \
		usr/lib/$pkgname/libdfs-server-ad-private-samba.so \
		usr/lib/$pkgname/libprinting-migrate-private-samba.so \
		usr/lib/$pkgname/libsmbd-base-private-samba.so \
		usr/lib/$pkgname/libsmbldaphelper-private-samba.so \
		usr/lib/$pkgname/pdb
}

libsmbclient() {
	pkgdesc="The SMB client library"
	depends="$pkgname-libs=$pkgver-r$pkgrel"
	amove \
		usr/lib/libsmbclient.so.*
}

# should only depend on samba-util-libs, libwbclient and samba-libs
_client_libs() {
	pkgdesc="Samba libraries used by clients"
	depends="$pkgname-libs=$pkgver-r$pkgrel"
	amove \
		usr/lib/$pkgname/libad-claims-private-samba.so \
		usr/lib/$pkgname/libauthn-policy-util-private-samba.so \
		usr/lib/$pkgname/libcli-ldap-private-samba.so \
		usr/lib/$pkgname/libcmdline-contexts-private-samba.so \
		usr/lib/$pkgname/libdsdb-garbage-collect-tombstones-private-samba.so \
		usr/lib/$pkgname/libdsdb-module-private-samba.so \
		usr/lib/$pkgname/libgpo-private-samba.so \
		usr/lib/$pkgname/libhttp-private-samba.so \
		usr/lib/$pkgname/libmscat-private-samba.so \
		usr/lib/$pkgname/libnetif-private-samba.so \
		usr/lib/$pkgname/libprinter-driver-private-samba.so \
		usr/lib/$pkgname/libregistry-private-samba.so \
		usr/lib/$pkgname/libsmbclient-raw-private-samba.so \
		usr/lib/libdcerpc.so.*
}

client() {
	pkgdesc="Samba client programs"
	depends="
		$pkgname-libs=$pkgver-r$pkgrel
		$pkgname-common=$pkgver-r$pkgrel
		"
	amove \
		usr/bin/cifsdd \
		usr/bin/dumpmscat \
		usr/bin/dbwrap_tool \
		usr/bin/mdsearch \
		usr/bin/mvxattr \
		usr/bin/nmblookup \
		usr/bin/oLschema2ldif \
		usr/bin/regdiff \
		usr/bin/regpatch \
		usr/bin/regshell \
		usr/bin/regtree \
		usr/bin/rpcclient \
		usr/bin/samba-regedit \
		usr/bin/sharesec \
		usr/bin/smbcacls \
		usr/bin/smbclient \
		usr/bin/smbcquotas \
		usr/bin/smbget \
		usr/bin/smbprint \
		usr/bin/smbspool \
		usr/bin/smbtar \
		usr/bin/smbtree \
		usr/bin/wspsearch \
		usr/lib/$pkgname/smbspool_krb5_wrapper
}

# should not pull in samba-client-libs
_server_libs() {
	pkgdesc="Samba libraries shared by server and windbind"
	depends="$pkgname-libs=$pkgver-r$pkgrel"
	amove \
		usr/lib/$pkgname/libdcerpc-samba4-private-samba.so \
		usr/lib/$pkgname/libidmap-private-samba.so \
		usr/lib/$pkgname/libnss-info-private-samba.so
}

# should not pull in samba-client-libs
winbind() {
	pkgdesc="Samba user and group resolver"
	depends="
		$pkgname-libs=$pkgver-r$pkgrel
		$pkgname-common=$pkgver-r$pkgrel
		"
	install="winbind.pre-install winbind.pre-upgrade winbind.post-install
		winbind.post-upgrade"
	amove \
		usr/sbin/winbindd \
		usr/lib/$pkgname/idmap \
		usr/lib/$pkgname/nss_info
	install -d -g winbind -m 750 \
		"$subpkgdir"/var/cache/$pkgname/winbindd_privileged
}

# should not depend on any other samba package
_util_libs() {
	pkgdesc="Samba utility libraries"
	depends=
	amove \
		usr/lib/libsamba-util.so.* \
		usr/lib/$pkgname/libgenrand-private-samba.so \
		usr/lib/$pkgname/libsocket-blocking-private-samba.so \
		usr/lib/$pkgname/libsamba-debug-private-samba.so \
		usr/lib/$pkgname/libtime-basic-private-samba.so \
		usr/lib/$pkgname/libsys-rw-private-samba.so \
		usr/lib/$pkgname/libiov-buf-private-samba.so \
		usr/lib/$pkgname/libcom-err-private-samba.so \
		usr/lib/$pkgname/libreplace-private-samba.so \
		usr/lib/$pkgname/libstable-sort-private-samba.so
}

# should only depend on samba-util-libs
libwbclient() {
	pkgdesc="Samba winbind client libraries"
	depends=
	amove usr/lib/libwbclient.so.*
}

_winbind_clients() {
	pkgdesc="Samba winbind client tools"
	depends="$pkgname-libs=$pkgver-r$pkgrel"
	amove \
		usr/bin/ntlm_auth \
		usr/bin/wbinfo
}

_libnss_winbind() {
	pkgdesc="Samba winbind NSS plugin"
	depends=
	amove \
		usr/lib/libnss_winbind.so* \
		usr/lib/libnss_wins.so*
}

_winbind_krb5_locator() {
	pkgdesc="Samba winbind krb5 locator"
	depends="$pkgname-libs=$pkgver-r$pkgrel"
	amove \
		usr/lib/samba/krb5
}

_pam_winbind() {
	pkgdesc="PAM module for winbind"
	depends=

	amove usr/lib/security
}

dc() {
	pkgdesc="Samba AD Domain Controller"
	depends="
		$pkgname-libs=$pkgver-r$pkgrel
		$pkgname-common=$pkgver-r$pkgrel
		$pkgname-server=$pkgver-r$pkgrel
		$pkgname-winbind=$pkgver-r$pkgrel
		py3-$pkgname=$pkgver-r$pkgrel
		$_dc_deps
		"
	amove \
		usr/bin/samba-tool \
		usr/sbin/samba* \
		usr/share/$pkgname \
		usr/lib/$pkgname/auth/samba4.so \
		usr/lib/$pkgname/gensec \
		usr/lib/$pkgname/ldb \
		usr/lib/$pkgname/libsmbpasswdparser-private-samba.so \
		usr/lib/$pkgname/vfs/posix_eadb.so
}

_dc_libs() {
	pkgdesc="Samba AD Domain Controller libraries"
	depends="$pkgname-libs=$pkgver-r$pkgrel"
	amove \
		usr/lib/libdcerpc-samr.so.* \
		usr/lib/libdcerpc-server.so.* \
		usr/lib/libsamba-policy.* \
		usr/lib/$pkgname/bind9 \
		usr/lib/$pkgname/libHDB-SAMBA4-private-samba.so \
		usr/lib/$pkgname/libLIBWBCLIENT-OLD-private-samba.so \
		usr/lib/$pkgname/libauth-unix-token-private-samba.so \
		usr/lib/$pkgname/libauth4-private-samba.so \
		usr/lib/$pkgname/libdb-glue-private-samba.so \
		usr/lib/$pkgname/libdnsserver-common-private-samba.so \
		usr/lib/$pkgname/libgss-preauth-private-samba.so \
		usr/lib/$pkgname/libhdb-private-samba.so* \
		usr/lib/$pkgname/libkdc-private-samba.so* \
		usr/lib/$pkgname/libpac-private-samba.so \
		usr/lib/$pkgname/libposix-eadb-private-samba.so \
		usr/lib/$pkgname/libprocess-model-private-samba.so \
		usr/lib/$pkgname/libscavenge-dns-records-private-samba.so \
		usr/lib/$pkgname/libservice-private-samba.so \
		usr/lib/$pkgname/libshares-private-samba.so \
		usr/lib/$pkgname/process_model \
		usr/lib/$pkgname/service
}

server() {
	pkgdesc="Samba server"
	depends="
		$pkgname-libs=$pkgver-r$pkgrel
		$pkgname-common=$pkgver-r$pkgrel
		acl
		"
	amove \
		usr/sbin/nmbd \
		usr/sbin/smbd \
		usr/sbin/eventlogadm \
		usr/bin/smbstatus \
		\
		usr/lib/$pkgname/auth \
		usr/lib/$pkgname/libREG-FULL-private-samba.so \
		usr/lib/$pkgname/libRPC-WORKER-private-samba.so \
		usr/lib/$pkgname/libxattr-tdb-private-samba.so \
		usr/lib/$pkgname/rpcd_* \
		usr/lib/$pkgname/samba-bgqd \
		usr/lib/$pkgname/samba-dcerpcd \
		usr/lib/$pkgname/vfs
}

pidl() {
	pkgdesc="Perl IDL compiler"
	depends="perl"
	amove \
		usr/bin/pidl \
		usr/share/perl*
	rm -r "$pkgdir"/usr/lib/perl*
}

_py3() {
	pkgdesc="Samba python libraries"
	depends="
		$pkgname-libs=$pkgver-r$pkgrel
		py3-tdb
		"
	mkdir -p "$subpkgdir"/usr/lib
	mv "$pkgdir"/usr/lib/python* "$subpkgdir"/usr/lib/
}

_test() {
	pkgdesc="Samba server and client testing tools"
	depends="$pkgname-libs=$pkgver-r$pkgrel"
	amove \
		usr/bin/gentest \
		usr/bin/locktest \
		usr/bin/masktest \
		usr/bin/ndrdump \
		usr/bin/smbtorture \
		usr/lib/$pkgname/libdlz-bind9-for-torture-private-samba.so \
		usr/lib/$pkgname/libtorture-private-samba.so
}

# avoid samba-libs and libsmbclient depending on pam
_libauth() {
	pkgdesc="Samba auth library shared by common-tools, server and clients"
	depends="$pkgname-libs=$pkgver-r$pkgrel"

	amove usr/lib/$pkgname/libauth-private-samba.so
}

# should only depend on samba-util-libs and libwbclient
libs() {
	pkgdesc="Samba core libraries shared by common-tools, server and clients"
	depends="
		$pkgname-util-libs=$pkgver-r$pkgrel
		libwbclient=$pkgver-r$pkgrel
		"
	# heimdal libs
	amove \
		usr/lib/$pkgname/libasn1-private-samba.so* \
		usr/lib/$pkgname/libgssapi-private-samba.so* \
		usr/lib/$pkgname/libhcrypto-private-samba.so* \
		usr/lib/$pkgname/libheimbase-private-samba.so* \
		usr/lib/$pkgname/libheimntlm-private-samba.so* \
		usr/lib/$pkgname/libhx509-private-samba.so* \
		usr/lib/$pkgname/libkrb5-private-samba.so* \
		usr/lib/$pkgname/libroken-private-samba.so* \
		usr/lib/$pkgname/libwind-private-samba.so*

	amove \
		usr/lib/$pkgname/libCHARSET3-private-samba.so \
		usr/lib/$pkgname/libMESSAGING-SEND-private-samba.so \
		usr/lib/$pkgname/libMESSAGING-private-samba.so \
		usr/lib/$pkgname/libaddns-private-samba.so \
		usr/lib/$pkgname/libads-private-samba.so \
		usr/lib/$pkgname/libasn1util-private-samba.so \
		usr/lib/$pkgname/libauthkrb5-private-samba.so \
		usr/lib/$pkgname/libcli-cldap-private-samba.so \
		usr/lib/$pkgname/libcli-ldap-common-private-samba.so \
		usr/lib/$pkgname/libcli-nbt-private-samba.so \
		usr/lib/$pkgname/libcli-smb-common-private-samba.so \
		usr/lib/$pkgname/libcli-spoolss-private-samba.so \
		usr/lib/$pkgname/libcliauth-private-samba.so \
		usr/lib/$pkgname/libclidns-private-samba.so \
		usr/lib/$pkgname/libcluster-private-samba.so \
		usr/lib/$pkgname/libcmdline-private-samba.so \
		usr/lib/$pkgname/libcmocka-private-samba.so \
		usr/lib/$pkgname/libcommon-auth-private-samba.so \
		usr/lib/$pkgname/libdbwrap-private-samba.so \
		usr/lib/$pkgname/libdcerpc-pkt-auth-private-samba.so \
		usr/lib/$pkgname/libdcerpc-samba-private-samba.so \
		usr/lib/$pkgname/libevents-private-samba.so \
		usr/lib/$pkgname/libflag-mapping-private-samba.so \
		usr/lib/$pkgname/libgensec-private-samba.so \
		usr/lib/$pkgname/libgse-private-samba.so \
		usr/lib/$pkgname/libinterfaces-private-samba.so \
		usr/lib/$pkgname/libkrb5samba-private-samba.so \
		usr/lib/$pkgname/libldbsamba-private-samba.so \
		usr/lib/$pkgname/liblibcli-lsa3-private-samba.so \
		usr/lib/$pkgname/liblibcli-netlogon3-private-samba.so \
		usr/lib/$pkgname/liblibsmb-private-samba.so \
		usr/lib/$pkgname/libmessages-dgm-private-samba.so \
		usr/lib/$pkgname/libmessages-util-private-samba.so \
		usr/lib/$pkgname/libmsghdr-private-samba.so \
		usr/lib/$pkgname/libmsrpc3-private-samba.so \
		usr/lib/$pkgname/libndr-samba-private-samba.so \
		usr/lib/$pkgname/libndr-samba4-private-samba.so \
		usr/lib/$pkgname/libnpa-tstream-private-samba.so \
		usr/lib/$pkgname/libsamba-cluster-support-private-samba.so \
		usr/lib/$pkgname/libsamba-modules-private-samba.so \
		usr/lib/$pkgname/libsamba-security-private-samba.so \
		usr/lib/$pkgname/libsamba-sockets-private-samba.so \
		usr/lib/$pkgname/libsamba3-util-private-samba.so \
		usr/lib/$pkgname/libsamdb-common-private-samba.so \
		usr/lib/$pkgname/libsecrets3-private-samba.so \
		usr/lib/$pkgname/libserver-id-db-private-samba.so \
		usr/lib/$pkgname/libserver-role-private-samba.so \
		usr/lib/$pkgname/libsmb-transport-private-samba.so \
		usr/lib/$pkgname/libsmbd-shim-private-samba.so \
		usr/lib/$pkgname/libtalloc-report-printf-private-samba.so \
		usr/lib/$pkgname/libtalloc-report-private-samba.so \
		usr/lib/$pkgname/libtdb-wrap-private-samba.so \
		usr/lib/$pkgname/libtrusts-util-private-samba.so \
		usr/lib/$pkgname/libutil-reg-private-samba.so \
		usr/lib/$pkgname/libutil-setid-private-samba.so \
		usr/lib/$pkgname/libutil-tdb-private-samba.so \
		usr/lib/libdcerpc-binding.so.* \
		usr/lib/libndr-krb5pac.so.* \
		usr/lib/libndr-nbt.so.* \
		usr/lib/libndr-standard.so.* \
		usr/lib/libndr.so.* \
		usr/lib/libsamba-credentials.so.* \
		usr/lib/libsamba-errors.so.* \
		usr/lib/libsamba-hostconfig.so.* \
		usr/lib/libsamba-passdb.so.* \
		usr/lib/libsamdb.so.* \
		usr/lib/libsmbconf.so.* \
		usr/lib/libsmbldap.so.* \
		usr/lib/libtevent-util.so.*

	# exit with error if some stuff stayed at main pack
	local leftovers="$(find "$pkgdir" -type f)"
	if [ -n "$leftovers" ]; then
		error "files left in main package:"
		echo "$leftovers" >&2
		return 1
	fi
}

sha512sums="
a666fc76dad2d9a68e802454555d2e93f7f71c2781ca5d11cf2fe8af046990b4be6677bbc754298613173849efb4387c16c2fd5557d65ba8b5a1ac02bd8c542a  samba-4.20.5.tar.gz
b7906d66fe55a980a54161ee3f311b51bcbce76b8d4c8cc1ba6d0c5bdf98232cb192b9d2c1aa7b3e2742f5b9848c6cf429347940eefe66c3e0eda1d5aac1bf93  musl_uintptr.patch
14666954aec4a0bc7a6730ba3a9afdbd4e27c083a038d9a1f5a033e4f0a42bc8408906612ea51f74bf743ff8a225242e54b0a518367fe526b110639bfbfdd071  default-config.patch
fdd31d53cd96bf4f67f74abd770493d04f6330f31654ad445e69f4c445b97e211db30049ddf51591e3ab733c4b62bef3436725da89c566c5d8e17e1b26b1fb19  samba.initd
e5a4022aad21be7ad6bd067d60dd7bf447ae7191aecdd4081ccf5f08565ee5e13f592777749bc460773a20a830ef59c47faa322c55253b6ce4160f8285f74c46  samba.confd
3458a4e1f8a8b44c966afb339b2dca51615be049f594c14911fc4d8203623deee416b6fe881436e246fc7d49c97a2b3bf9c5f33ba774302b24190a1103d6b67d  samba.logrotate
"
